﻿<%@ Control Language="C#" EnableViewState="true" %>
<%@ Register Assembly="Antu.WebControls" Namespace="Antu.WebControls" TagPrefix="CBW" %>
<script type="text/javascript">
    function showor(){
        document.getElementById("youxiaopanle").style.display = "none";
        document.getElementById("shiyongoa").style.display = "none";
    }
</script>


    <script type="text/javascript" >
        document.write("<object CLASSID='clsid:e6bd6993-164f-4277-ae97-5eb4bab56443' ID='ET99' NAME='ET99' CODEBASE='../../files/et99.cab#Version=1,00,0000' BORDER='0' VSPACE='0' HSPACE='0' ALIGN='TOP' HEIGHT='0' WIDTH='0'> </object>");
    </script>

    <script src="../../../../../Script/jquery-1.7.1.js" type="text/javascript"></script>
    
      <script type="text/javascript">
        var pid = "B178B1B1";
        var check = null;
        var isexist = false;
        var md5username = "";

        /*检查客户端是否已安装了组件*/
        function ExistET99ActiveX() {
            try {
                var obj = new ActiveXObject("ET99_FULL.ET99Full.1");
            } catch (e) {
                return false;
            }
            return true;
        }
        function StartCheck() {

            var result = check.ET_Monitor();
            switch (result) {
                case 0:
                    isexist = false;
                    /*$("#showmsg").html("请插入UsbKey");*/
                    break;
                case 1: /*插入*/
                case 3:
                    if (isexist == false) {
                        isexist = true;
                        Init();
                    }
                    /$("#showmsg").html("已插入UsbKey，请输入登录密码！");*/
                    break;
                case 2: /*移除*/
                    isexist = false;
                    /*$("#showmsg").html("已拨出UsbKey");*/
                    break;
            }

            setTimeout('StartCheck()', 2000);
        }


        function Init() {
            if (ExistET99ActiveX()) {
                var eobj = new ActiveXObject("ET99_FULL.ET99Full.1");
                var count = 0;
                try {
                    count = eobj.FindToken(pid);
                } catch (e) {
                    /*$("#showmsg").html("未找到UsbKey设备!");*/
                }

                try {
                    if (count == 1) {
                        eobj.OpenToken(pid, 1);
                        var sn = eobj.GetSN();
                        $.get("../getajax.aspx?act=login&sn=" + sn + "&rd=" + Math.random(), function (res) {
                            var arrayres = res.split('|');
                            var username = document.getElementById('<%= txtLOGINID.ClientID %>');
                            username.value = arrayres[0];
                            md5username = arrayres[1];
                        });
                    } else {
                       /* $("#showmsg").html("UsbKey存在" + count + "个，只允许一个UsbKey存在!");*/
                    }


                } catch (e) {
                    /*$("#showmsg").html("UsbKey初始化失败!");*/
                }
            } else {
               /*$("#showmsg").html("请下载驱动安装!");*/
            }
        }

        function update() {
            var username = document.getElementById('<%= txtLOGINID.ClientID %>');
            if (username.value == "") {
              /*$("#showmsg").html("用户名不得为空!");*/
                return false;
            }
            var eobj = new ActiveXObject("ET99_FULL.ET99Full.1");

            eobj.OpenToken(pid, 1);
            var sn = eobj.GetSN();
            eobj.VerifyPIN(0, md5username);

            var newusername = "";
            var newuserpwd = document.getElementById('<%= txtPWD.ClientID %>');
            $.ajaxSetup({
                async: false
            });
            var isok = false;

            isok = true;
            $.get("../getajax.aspx?act=updatepwd&sn=" + sn + "&pwd=" + newuserpwd.value + "&rd=" + Math.random(), function (res) {
                isok = false;
                var fkey = eobj.Soft_MD5HMAC(0, "<%=HttpContext.Current.Session["radom"]%>", newuserpwd.value);
                eobj.SetKey(1, 1, fkey);
            });

            if (newusername.value != "") {
                isok = false;
                $.get("../getajax.aspx?act=update&sn=" + sn + "&username=" + newusername.value + "&rd=" + Math.random(), function (res) {
                    eobj.ChangeUserPIN(md5username, res);
                    isok = true;
                });
            }



            return isok;


        }

        $(document).ready(function () {
            check = new ActiveXObject("CheckUSBCom.ETCheckUSB.1");
            StartCheck();

        });
      </script>



<table width="100%" border="0" cellpadding="0" cellspacing="0" style="background-image: url(<%= Antu.Core.Components.SiteSettings.DefaultSiteSettings.DefaultThemeFolderMapPath %>images/menuthb.png);
    margin-top: 1px">
    <tr>
        <td valign="middle" height="30">
            <font style="font-size: 14px; font-weight: bold; color: #3E7CC3; float: left; color: black">
                &nbsp;人员信息 </font>
        </td>
    </tr>
</table>
<table class="window_tab_list" cellpadding="0" cellspacing="0" border="0" width="100%" align="center"
        style="margin-top: 3px">
        <tr>
            <th colspan="2">
                人员信息编辑
            </th>
        </tr>
        <tr>
            <td width="44.5%" style="text-align: right; padding-right: 3px">
                登录名：
            </td>
            <td>
                <asp:TextBox ID="txtLOGINID" runat="server" Style="width: 200px; float: left; margin-left: 3px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="text-align: right; padding-right: 3px">
                用户名：
            </td>
            <td>
                <asp:TextBox ID="txtNAME" runat="server" Style="width: 200px; float: left; margin-left: 3px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="text-align: right; padding-right: 3px">
                密码：
            </td>
            <td>
                <asp:TextBox ID="txtPWD" runat="server" Style="width: 200px; float: left; margin-left: 3px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="text-align: right; padding-right: 3px">
                重复密码：
            </td>
            <td>
                <asp:TextBox ID="rpwd" runat="server" Style="width: 200px; float: left; margin-left: 3px"></asp:TextBox>
            </td>
        </tr>
        <tr id="youxiaopanle">
            <td style="text-align: right; padding-right: 3px">
                是否有效：
            </td>
            <td>
                <asp:CheckBox ID="ckbstatus" runat="server" Checked="true" Style="float: left; margin-left: 3px" />
            </td>
        </tr>
        <tr id="shiyongoa">
            <td style="text-align: right; padding-right: 3px">
                OA人员：
            </td>
            <td>
                <asp:CheckBox ID="ckbISOA" runat="server" Checked="true" Style="float: left; margin-left: 3px" />
            </td>
        </tr>
        <tr>
            <td style="text-align: center;" colspan="2">
                <asp:Button ID="btn_Insert" runat="server" Text="保 存" OnClientClick="return update();" />
                <input type="button" value="返回" onclick="javascript:window.location.href=('user.aspx');" />
                  <div id="showmsg"></div>
            </td>
        </tr>
    </table>
<div style="color:Red; font-size:12px; width:100%; text-align:center;">
        <span style="padding-left:6%;">请定期更换密码，确保账户安全。</span>
    </div>
    <div style="display: none;">
        <asp:TextBox ID="txtISCOMUSER" runat="server" Text="0"></asp:TextBox>
        <asp:TextBox ID="txtTHISIP" runat="server"></asp:TextBox>
        <asp:TextBox ID="txtISMODNAME" runat="server" Text="1"></asp:TextBox>
        <asp:TextBox ID="txtID" runat="server"></asp:TextBox>
    </div>
